 <?php
// 读取数据
$data = file('datafile.csv');
//$a = explode(',', $data[0]);
// 转化为数组
//foreach ($data as $line_num => $line) {
  //   echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
   // $data[$line_num] = explode(',', $line);
//}

//echo '<pre>';
//print_r($data);
//echo '</pre>';

?>  

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>学员信息</title>
    <!-- Bootstrap -->
    <link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    .studentinfo {
        margin-top: 50px;
    }
    </style>
</head>

<body>
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default studentinfo">
                    <div class="panel-heading">
                        <h3 class="panel-title">学员信息</h3>
                    </div>
                    <div class="panel-body">
                        <table class="table table-striped">
                            <tr>
                                <td>序号
                                </td>
                                <td>姓名
                                </td>
                                <td>学号
                                </td>
                                <td>课节
                                </td>
                                <td>地址
                                </td>
                            </tr>
                           
                         <?php foreach ($data as $line_num => $line): ?>
                <tr>
                    <td>
                        <?php echo $line_num ?>
                    </td>
                    <td>
                        <?php echo $line[0] ?>
                    </td>
                    <td>
                        <?php echo $line[1] ?>
                    </td>
                    <td>
                        <?php echo $line[2] ?>
                    </td>
                    <td>
                        <a href="<?php echo $line[3] ?>" target="_black"><?php echo $line[3] ?></a>
                    </td>
                </tr>
                <?php endforeach;?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</body>

</html>

